Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add directory based open & create calls #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

movitto
Copy link
Contributor

@movitto movitto commented Jun 19, 2019

Since in the examples and most implementations NuDB will use 'nudb.[dat|key|log]' files to persistently store the DB, this patch simplifies this 'default' scenario, allowing the end user to create and access a database given the directory in which those files reside.

Thus the user can now open the db like so:

store.open("/path/to/db/", error_code)

@vinniefalco
Copy link
Member

This is a reasonable quality of life feature in principle, but it should not require accessing private members of store. It should be implementable as a free function using only public interfaces:

open_dir(store, "/path/to/db/", ec);

@movitto
Copy link
Contributor Author

movitto commented Jun 20, 2019

Hey @vinniefalco I'm afraid I'm not following. The basic_store public/private access control is still in effect and this patch just overloads nudb::create and nudb::basic_store#open to facilitate dir based initialization. Can you help me understand your design principles behind preferring external wrapper methods to extending the base_store interface?

@vinniefalco
Copy link
Member

Init files from default names under dir
@movitto
Copy link
Contributor Author

movitto commented Jun 25, 2019

OK @vinniefalco thanks for the link, I just bought a copy of "effective c++" for future reference!

I incorporated the feedback you had for this patch from this PR and #75. Specifically:

  • open_dir is now a function in the nudb namespace, constructing the default file paths under the specified base dir, and then invoking the 'open' method on the specified store
  • filesystem helpers were embedded in the project so as to remove the dependency on 'boost::filesystem'. In addition to the provided 'path_cat' function, the following others were added: 'path_exists', 'is_dir', 'mkdir_p'. I should note that while I attempted to support win32 functionality I do not have an environment to test it on.
  • a file.ipp implementation file was added to implement the previous
  • tests were added to the test suite verifying directory based creation and access
  • default path helpers were made inline, when the string_type/string_view patch is available I can rebase this ontop of that

Let me know if there's anything else!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants